package com.tianyalei.wolf.sample.activity.wxcircle.widget.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.tianyalei.wolf.mddesignlib.utils.FileUtil;
import com.tianyalei.wolf.sample.R;
import com.tianyalei.wolf.sample.view.BaseDialog;

/**
 * Created by wolf on 2016/4/7.
 */
public class SavePicDialog extends BaseDialog {
    private Context mContext;
    private String url;

    public SavePicDialog(Context context, String url) {
        super(context, R.style.base_dialog);
        mContext = context;
        this.url = url;
    }

    @Override
    protected int setLayoutView() {
        return R.layout.dialog_save_pic;
    }

    @Override
    protected void init(View mDialogView) {
        TextView share = (TextView) findViewById(R.id.share_to_friend);
        TextView save = (TextView) findViewById(R.id.save_to_phone);
        share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dismiss();
            }
        });
        save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //根据url或者fresco加载的图片缓存地址
                FileUtil.savePic(mContext, "Sample", url);

                dismiss();
            }
        });
    }
}
